package cn.edu.neu.service.impl;

import cn.edu.neu.dao.GoodsDao;
import cn.edu.neu.model.Goods;
import cn.edu.neu.model.User;
import cn.edu.neu.service.GoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsDao goodsDao;
    @Override
    public PageInfo<Goods> getGoodsList(Integer page, Integer count) {

        PageHelper.startPage(page,count);
        List<Goods> goodslist= goodsDao.selectGoods();
        PageInfo<Goods> pageInfo=new PageInfo<>(goodslist);
        return pageInfo;
    }

    @Override
    public PageInfo<Goods> FindGoodsByName(Integer page,Integer count,String goods_name) {

        PageHelper.startPage(page,count);
        List<Goods> goodslist= goodsDao.FindGoodsByName(goods_name);
        PageInfo<Goods> pageInfo=new PageInfo<>(goodslist);
        return pageInfo;
    }

    @Override
    public int addGoods(Goods goods) {
        return goodsDao.insert(goods);
    }
}
